/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.intec.matsab.persistence;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author matilde
 */
@Entity
@Table(name = "Clase")
@NamedQueries({@NamedQuery(name = "Clase.findByIdAsignatura", query = "SELECT c FROM Clase c WHERE c.clasePK.idAsignatura = :idAsignatura"), @NamedQuery(name = "Clase.findByIdTrimestre", query = "SELECT c FROM Clase c WHERE c.clasePK.idTrimestre = :idTrimestre"), @NamedQuery(name = "Clase.findByNumero", query = "SELECT c FROM Clase c WHERE c.clasePK.numero = :numero"), @NamedQuery(name = "Clase.findByIdClase", query = "SELECT c FROM Clase c WHERE c.clasePK.idClase = :idClase"), @NamedQuery(name = "Clase.findByAula", query = "SELECT c FROM Clase c WHERE c.aula = :aula"), @NamedQuery(name = "Clase.findByDia", query = "SELECT c FROM Clase c WHERE c.dia = :dia"), @NamedQuery(name = "Clase.findByHoraInicio", query = "SELECT c FROM Clase c WHERE c.horaInicio = :horaInicio"), @NamedQuery(name = "Clase.findByHoraFin", query = "SELECT c FROM Clase c WHERE c.horaFin = :horaFin")})
public class Clase implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ClasePK clasePK;
    @Column(name = "aula", nullable = false)
    private String aula;
    @Column(name = "dia", nullable = false)
    private int dia;
    @Column(name = "hora_inicio", nullable = false)
    @Temporal(TemporalType.TIME)
    private Date horaInicio;
    @Column(name = "hora_fin", nullable = false)
    @Temporal(TemporalType.TIME)
    private Date horaFin;
    @JoinColumns({@JoinColumn(name = "numero", referencedColumnName = "numero", insertable = false, updatable = false), @JoinColumn(name = "idTrimestre", referencedColumnName = "idTrimestre", insertable = false, updatable = false), @JoinColumn(name = "idAsignatura", referencedColumnName = "idAsignatura", insertable = false, updatable = false)})
    @ManyToOne
    private Seccion seccion;
    @Transient
    private boolean selected;
    

    public Clase() {
    }

    public Clase(ClasePK clasePK) {
        this.clasePK = clasePK;
    }

    public Clase(ClasePK clasePK, String aula, int dia, Date horaInicio, Date horaFin) {
        this.clasePK = clasePK;
        this.aula = aula;
        this.dia = dia;
        this.horaInicio = horaInicio;
        this.horaFin = horaFin;
    }

    public Clase(String idAsignatura, int idTrimestre, int numero, int idClase) {
        this.clasePK = new ClasePK(idAsignatura, idTrimestre, numero, idClase);
    }

    public ClasePK getClasePK() {
        return clasePK;
    }

    public void setClasePK(ClasePK clasePK) {
        this.clasePK = clasePK;
    }

    public String getAula() {
        return aula;
    }

    public void setAula(String aula) {
        this.aula = aula;
    }

    public int getDia() {
        return dia;
    }

    public void setDia(int dia) {
        this.dia = dia;
    }

    public Date getHoraInicio() {
        return horaInicio;
    }

    public void setHoraInicio(Date horaInicio) {
        this.horaInicio = horaInicio;
    }

    public Date getHoraFin() {
        return horaFin;
    }

    public void setHoraFin(Date horaFin) {
        this.horaFin = horaFin;
    }

    public Seccion getSeccion() {
        return seccion;
    }

    public void setSeccion(Seccion seccion) {
        this.seccion = seccion;
    }
    
    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (clasePK != null ? clasePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Clase)) {
            return false;
        }
        Clase other = (Clase) object;
        if ((this.clasePK == null && other.clasePK != null) || (this.clasePK != null && !this.clasePK.equals(other.clasePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.intec.matsab.persistence.Clase[clasePK=" + clasePK + "]";
    }

}
